package com.cyx.spring.context;

/**
 * ApplicationContextUtils
 *
 * @author yongxiang
 * @date 2024/10/24 15:09
 * @desc
 */
public class ApplicationContextUtils {
    private static ConfigurableApplicationContext configurableApplicationContext;

    public  static ApplicationContext getApplicationContext() {
        return configurableApplicationContext;
    }

    public static void setConfigurableApplicationContext(ConfigurableApplicationContext applicationContext){
        configurableApplicationContext = applicationContext;
    }

    public static <T> T getBean(Class<T> clazz){
        return configurableApplicationContext.getBean(clazz);
    }

    public static <T> T getBean(String name){
        return configurableApplicationContext.getBean(name);
    }

}
